Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements basic BOM/Codec detection, PEP compliance and style guide pass, Python3 modernisation #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lili7h
Copy link
Contributor

@lili7h lili7h commented Sep 8, 2024

I guess im coming back to this old project again haha.

I noted that if you accidentally specified the wrong codec, Python would not appropriately strip the BOM char out of the file, which would result in the regex to identify the first Key failing to match because the line didn't start with a ". 99% of the time, you will be fine just using the default UTF8, but sometimes Valve throws a curveball at you with a Source 1 UTF-16 encoded file.

The current implementation will pick up a BOM char if it exists, and convert that to the appropriate encoding string, then will drop a warning about overriding the specified encoding with the new one. You can override this by using the ignore_bom=True flag in class init.

I also ran some styling sweeps over the file to make it a little more happy with the PEP style guides, and removed references to Py2 functions. If you want to keep Py2 support, then I can go back and do some proper Py2/3 inter-support with the futures/futurize package.

Happy to take comments/feedback on this and make changes as needed.

Copy link
Owner

@gorgitko gorgitko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, great job, and thanks so much for keeping this project alive with a modern touch! 😎

I am not sure if Python 2 support is worth the extra work. Let's focus on Py3.

One nit: unify quotes. Let's use either " or '

I don’t have any plans for this repo moving forward, and you clearly know what you're doing. So feel free to take it over! 👨‍🍼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants